/**   
 * @Title: ConListAdapter.java 
 * @Package com.cdtv.home.adapter 
 * @Description: 
 * @author zhuw
 * @date 2012-7-18 下午3:27:20 
 */
package com.adpter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.ocean.util.common.StringUtil;
import com.common.method.ServerPath;
import com.matang.R;
import com.modle.User;
import com.modle.UserResume;
import com.modle.UserResumeWrapper;
import com.util.OUtil;

/**
 * 
 * @ClassName:ZpInfoListAdapter
 * @Description:TODO
 * @author zhuw
 * @date 2013-7-24 下午2:30:06
 */
public class ReceResumeListAdapter extends CusBaseAdapter {
	private List<UserResumeWrapper> list;
	private Context context;

	/**
	 * @param list
	 * @param context
	 */
	public ReceResumeListAdapter(List<UserResumeWrapper> list, Context context) {
		super();
		this.list = list;
		this.context = context;
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View view, ViewGroup parent) {
		ViewHolder vh = null;
		if (view == null) {
			view = LayoutInflater.from(context).inflate(
					R.layout.list_item_rece_resume, null);
			vh = new ViewHolder();
			vh.ageTv = (TextView) view.findViewById(R.id.age_tv);
			vh.weightTv = (TextView) view.findViewById(R.id.weight_tv);
			vh.heightTv = (TextView) view.findViewById(R.id.height_tv);
			vh.thumbIv = (ImageView) view.findViewById(R.id.thumb_iv);
			vh.sexIv = (ImageView) view.findViewById(R.id.sex_iv);
			vh.bgIv = (ImageView) view.findViewById(R.id.bg_iv);
			view.setTag(vh);
		} else {
			vh = (ViewHolder) view.getTag();

		}
		UserResume data = list.get(position).rStruct;
		if (data != null) {

			vh.ageTv.setText("A:" + data.age);
			vh.heightTv.setText("H:  " + data.height);
			vh.weightTv.setText("W:  " + data.weight);
			if (!StringUtil.isNull(data.sex)&&data.sex.equalsIgnoreCase(User.MALE_M)) {
				vh.sexIv.setImageResource(R.drawable.male_i);
			} else {
				vh.sexIv.setImageResource(R.drawable.female_i);

			}
			imageLoader.bind(vh.thumbIv,ServerPath.SERVER+data.thumb, null,R.drawable.default_head);

		} else {
			vh.ageTv.setText("A:");
			vh.heightTv.setText("H:  ");
			vh.weightTv.setText("W:  ");
			vh.sexIv.setImageResource(R.drawable.female_i);

		}
      OUtil.setThumbBg(data.userInfo, vh.bgIv);
		return view;
	}

	class ViewHolder {
		TextView ageTv, heightTv, weightTv;
		ImageView thumbIv, sexIv,bgIv;

	}

}
